<?php

namespace App\Modules\Diagnose\Services;

use  App\Modules\Diagnose\Models\Graphic;

class GraphicService
{

    public static function getList($data=[]) {
        return Graphic::getList($data);
    }

    public static function get($user_id,$group_id){
        return Graphic::get($user_id,$group_id);
    }

    public static function getDetails($user_id,$group_id,$size){
        return Graphic::getDetails($user_id,$group_id,$size);
    }


    public static function add($data=[]){
        return Graphic::add($data);
    }

    /**
     * @param $param
     * @return mixed
     */
    static function updateSave($param)
    {
        // TODO check
        return Graphic::updateSave($param);

    }

    /**
     * 咨询记录列表
     */
    static function recordsList($user_id,$size){
        $dataList = Graphic::from('diagnose AS D')->select(['D.*','C.name','C.photo','C.position','C.signature'])
                    ->leftJoin('doctor AS C','D.doctor_id','=','C.id')->where('D.user_id',$user_id)->where('D.group_id',0)->where('D.doctor_id','!=',0)->where('D.status','>',0)->orderBy('D.updated_at','DESC')->paginate($size);
        return $dataList;
    }

    static function getById($id) {
        return Graphic::find($id);
    }
}